#include "S_PS2.h"

uint8_t Comd[3] = {0x01, 0x42,0x00};											  //开始命令。请求数据
uint8_t Ps2Data[9] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //数据存储数组

void GetPs2Data(void)
{
	HAL_GPIO_WritePin(PS2_CS_GPIO_Port, PS2_CS_Pin, 0);
	HAL_SPI_TransmitReceive(&hspi1, &Comd[0], &Ps2Data[0], 1, 10);
	HAL_Delay(1);
	HAL_SPI_TransmitReceive(&hspi1, &Comd[1], &Ps2Data[1], 1, 10);
	HAL_Delay(1);
	// HAL_SPI_Receive(&hspi1,&Ps2Data[2],7,100);
	HAL_SPI_TransmitReceive(&hspi1, &Comd[2], &Ps2Data[2], 7, 10);
	HAL_GPIO_WritePin(PS2_CS_GPIO_Port, PS2_CS_Pin, 1);
}